//部分控制器
var app = angular.module('myApp.controllers');

//example首页
app.controller('infoIndex', ["$scope", "utilService", "$rootScope", function ($scope, utilService, $rootScope) {
  /*点击进入详情修改*/
  $scope.showDetail = function (id) {
    utilService.$state.go('info.detail', {edit: id});
  }
  /*时间选择*/
  var now = new Date();
  var today = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate();
  $("#dateTime").datetimePicker({
    min: today,
    onClose: function (res) {
      console.log(res)
    }
  });
  /*点击预览头像*/
  $scope.showAvatar = function () {
    utilService.$state.go('info.avatar');
  }





  $scope.$on('$ionicView.beforeEnter', function () {
    //页面刚加载
    utilService.$ionicLoading.show(HX_CONFIG.loadingBase);
  }, false);
  $scope.$on('$ionicView.afterEnter', function () {
    utilService.$rootScope.rootData.title = '个人信息';
    //页面加载完成
    utilService.$ionicLoading.hide();
  }, false);
  $rootScope.$on('$ionicView.beforeLeave', function (e, ion) {
    //页面离开之前
    //alertPopup && alertPopup.close();

  }, false);

}]);
//example首页
app.controller('infoDetail', ["$scope", "utilService", "$rootScope", function ($scope, utilService, $rootScope) {
  /*标题*/
  $scope.title = '';
  $scope.edit = utilService.$stateParams.edit;
  if($scope.edit=='1'){
    $scope.title = '设置昵称';
  }else if($scope.edit=='2'){
    $scope.title = '设置手机号';
  }

  $scope.$on('$ionicView.beforeEnter', function () {
    //页面刚加载
    utilService.$ionicLoading.show(HX_CONFIG.loadingBase);
  }, false);
  $scope.$on('$ionicView.afterEnter', function () {
    utilService.$rootScope.rootData.title = $scope.title;
    //页面加载完成
    utilService.$ionicLoading.hide();
  }, false);
  $rootScope.$on('$ionicView.beforeLeave', function (e, ion) {
    //页面离开之前
    //alertPopup && alertPopup.close();

  }, false);

}]);
app.controller('infoAvatar', ["$scope", "utilService", "$rootScope", function ($scope, utilService, $rootScope) {
  /*标题*/
  $scope.title = '';
  $scope.edit = utilService.$stateParams.edit;
  if($scope.edit=='1'){
    $scope.title = '设置昵称';
  }else if($scope.edit=='2'){
    $scope.title = '设置手机号';
  }

  $scope.$on('$ionicView.beforeEnter', function () {
    //页面刚加载
    utilService.$ionicLoading.show(HX_CONFIG.loadingBase);
  }, false);
  $scope.$on('$ionicView.afterEnter', function () {
    utilService.$rootScope.rootData.title = '我的头像';
    //页面加载完成
    utilService.$ionicLoading.hide();
  }, false);
  $rootScope.$on('$ionicView.beforeLeave', function (e, ion) {
    //页面离开之前
    //alertPopup && alertPopup.close();

  }, false);

}]);